package com.cgx.entity.message;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;

/**
 * @author chenguanxin
 * @date 2021-05-25 21:18
 */
@Data
@Document(collection = "session")
public class Session {
    @Id
    @Field("id")
    private String id;
    @Field("session_id")
    private String sessionId;
    @Field("session_type")
    private String sessionType;
    @Field("last_message_time")
    private Date lastMessageTime;
    @Field("create_by")
    private String createBy;
    @Field("create_time")
    private Date createTime;
    @Field("update_by")
    private String updateBy;
    @Field("update_time")
    private Date updateTime;
    @Field("is_delete")
    private Integer isDelete;

    public static Session getSession(String userId) {
        Session session = new Session();
        session.setLastMessageTime(new Date());
        session.setCreateBy(userId);
        session.setCreateTime(new Date());
        session.setUpdateBy(userId);
        session.setUpdateTime(new Date());
        session.setIsDelete(0);
        return session;
    }
}
